//
//  UIImage+CJY.m
//  YiZheWangXM
//
//  Created by apple on 14-8-17.
//  Copyright (c) 2014年 yzw. All rights reserved.
//

#import "UIImage+CJY.h"

@implementation UIImage (CJY)
#pragma mark 加载全屏的图片
// new_feature_1.png
+ (UIImage *)fullscrennImage:(NSString *)imgName
{
    // 1.如果是iPhone5，对文件名特殊处理
    if (Screen4INCH) {
        // 1.1.获得文件拓展名
        NSString *ext = [imgName pathExtension];
        
        // 1.2.删除最后面的扩展名
        imgName = [imgName stringByDeletingPathExtension];
        
        // 1.3.拼接-568h@2x
        imgName = [imgName stringByAppendingString:@"_480"];
        
        // 1.4.拼接扩展名
        imgName = [imgName stringByAppendingPathExtension:ext];
    }
    
    // 2.加载图片
    return [self imageNamed:imgName];
}
#pragma mark 可以自由拉伸的图片
+ (UIImage *)resizedImage:(NSString *)imgName
{
    return [self resizedImage:imgName xPos:0.5 yPos:0.5];
}

+ (UIImage *)resizedImage:(NSString *)imgName xPos:(CGFloat)xPos yPos:(CGFloat)yPos
{
    UIImage *image = [UIImage imageNamed:imgName];
    return [image stretchableImageWithLeftCapWidth:image.size.width * xPos topCapHeight:image.size.height * yPos];
}
@end
